-- This example gives formulas for quadratic and cubic roots and uses the image command to visualize a complex function. Utility functions for complex numbers are at the end of the document.
plot {root1,root2,root3} -- show locations of roots
plot z({X,0})[1]/Zmax -- plot the real part of z for real x
-- This should be zero at real roots. On the plotted surface, real roots are located along y=0 so the real cubic plotted in this way should pass though its real roots.
----------- utility functions for complex numbers ------
-- Arrays can be used to represent complex numbers. Addition, subtraction and multiplication by a real can be done directly. The following functions implement other basic operations on complex numbers. Note that a real number r must be written as {r,0}.